﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Dev.Net.Contracts;
using System.IdentityModel.Claims;

namespace Dev.Net.Server
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class DevNetService : IDevNetService
    {
        public static string Version
        {
            get
            {
                System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                return string.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build);
            }
        }


        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }


        public Assembly GetAssembly()
        {
            return new Assembly() { ID = 1 };
        }

        public List<string> Echo()
        {
            List<string> claims = new List<string>();

            foreach (ClaimSet set in OperationContext.Current.ServiceSecurityContext.AuthorizationContext.ClaimSets)
            {
                foreach (Claim claim in set)
                {
                    claims.Add(string.Format("{0} - {1} - {2}",
                        claim.ClaimType, claim.Resource.ToString(), claim.Right));
                }
            }

            return claims;

        }
    }
}
